﻿// 基类
using UnityEngine;

public class MovableObject : MonoBehaviour
{
    public float speed = 5f;

    protected void Move(Vector3 direction)
    {
        transform.Translate(direction * speed * Time.deltaTime);
    }
}

// 子类
public class Player1: MovableObject
{
    void Update()
    {
        Move(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
    }
}

public class Enemy1: MovableObject
{
    void Update()
    {
        Move(Vector3.forward);
    }
}